package database

import (
	"github.com/jinzhu/gorm"
	// mysql
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

// DB 数据库
var DB *gorm.DB

func init() {
	var err error
	DB, err = gorm.Open("mysql", "root:123456@/poetry?charset=utf8&parseTime=True&loc=Local")

	if err != nil {
		panic("connect mysql failed")
	}

	err = DB.DB().Ping()
	if err != nil {
		defer DB.Close()
	}
}
